// transmission-remote-dotnet
// https://code.google.com/p/transmission-remote-dotnet-magnet-friendly-edition/
// Copyright (C) 2009  Alan F, 2013-2014  __alex
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using System.Text;

namespace TransmissionRemoteDotnet
{
    partial class AboutDialog : CultureForm
    {
        public AboutDialog()
        {
            InitializeComponent();
            Version version = AssemblyVersion;
            this.Text = String.Format("About {0}", AssemblyTitle);
            this.labelProductName.Text = AssemblyTitle;
            this.labelVersion.Text = String.Format("v{0}.{1} ({2} {3})", version.Major, version.Minor, "build" /* OtherStrings.Build.ToLower() */, version.Build);
            this.labelCopyright.Text = String.Format("{0} {1}", AssemblyCopyright, Encoding.ASCII.GetString(Convert.FromBase64String("")));
            this.tableLayoutPanel.ColumnStyles[0].Width = this.labelProductName.Width + 8;

            // Identify what the first Link is.
            labelOriginalAppLinks.LinkArea = new System.Windows.Forms.LinkArea(18, 8);
            labelOriginalAppLinks.Links[0].LinkData = "https://code.google.com/p/transmission-remote-dotnet/";

            // Identify what the first Link is.
            labelMFELinks.LinkArea = new System.Windows.Forms.LinkArea(24, 8);
            labelMFELinks.Links[0].LinkData = "https://code.google.com/p/transmission-remote-dotnet-magnet-friendly-edition/";
            // add more links
            labelMFELinks.Links.Add(35, 5, "http://groups.google.com/group/transmission-remote-dotnet-magnet-friendly-edition");
        }

        private void labelHomepageLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            labelOriginalAppLinks.LinkVisited = true;
            System.Diagnostics.Process.Start(e.Link.LinkData as string);
        }

        private void labelMFELinks_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            labelMFELinks.LinkVisited = true;
            System.Diagnostics.Process.Start(e.Link.LinkData as string);
        }

        #region Assembly Attribute Accessors

        public static string AssemblyTitle
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
                if (attributes.Length > 0)
                {
                    AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
                    if (titleAttribute.Title != "")
                    {
                        return titleAttribute.Title;
                    }
                }
                return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
            }
        }

        public static string AssemblyLocation
        {
            get
            {
                return Assembly.GetExecutingAssembly().Location;
            }
        }

        public static Version AssemblyVersion
        {
            get
            {
                return Assembly.GetExecutingAssembly().GetName().Version;
            }
        }

        public static string AssemblyDescription
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyDescriptionAttribute)attributes[0]).Description;
            }
        }

        public static string AssemblyProduct
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyProductAttribute)attributes[0]).Product;
            }
        }

        public static string AssemblyCopyright
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
            }
        }

        public static string AssemblyCompany
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyCompanyAttribute)attributes[0]).Company;
            }
        }
        #endregion
    }
}
